
var prmdform={
    nbSlide:0,
    nbCurrent:1,
    elemCurrent:null,
    elem: null,
    timer: null,

    init: function(elem){
        this.nbSlide = elem.find(".prmdf").length;

        //init carrousel
//        var num=6;
//this.nbCurrent=num;
this.nbCurrent=1;

        this.elem=elem;
        elem.find(".prmdf").hide();
        elem.find(".prmdf:first").show();
//        elem.find("#prmdf"+num).show();
        this.elemCurrent=elem.find(".prmdf:first");
        if (this.elemCurrent.hasClass('deactivated')){
            elem.find(".prmdf:first").hide();
            elem.find("#prmdf3").show();
            this.elemCurrent=elem.find("#prmdf3");
            this.nbCurrent=3;
        }
        //this.elem.parent().find("#ColRight").find("ul li:first").addClass("active");
          this.elem.find(".nextPrmdf").click(function(){
           
              prmdform.gotoSlide(( parseInt(prmdform.nbCurrent,10)+1));
          
      });
          this.elem.find(".prevPrmdf").click(function(){
              prmdform.gotoSlide( parseInt(prmdform.nbCurrent,10)-1);
              
      });
          $('.formRub').click(

                function(){
                    $('.sidenav').removeClass('active');
                    nbRub=$(this).attr('href');
                    prmdform.gotoSlide(nbRub);
                    $(this).addClass('active');
                    return false;
                }

            );
    },

    gotoSlide: function(num){

        if(num==this.nbCurrent){return false;}
        if(this.elem.find("#prmdf"+num).hasClass('deactivated')){
            return false;
        }
        /* fadeIn / Fadeout
        this.elemCurrent.fadeOut();
        this.elem.find("#slide"+num).fadeIn();*/

        //slide
        var sens=-1;

        if(num >this.nbCurrent){sens=1;}else{sens=-1;}
        //alert ( num +" "+this.nbCurrent)
        var cssDep={"left":sens*this.elem.width()};
        var cssFin={"left":-sens*(this.elem.width()+30)};

        this.elem.find("#prmdf"+num).show().css(cssDep);

        this.elem.find("#prmdf"+num).animate({"top":0,"left":0},500);
        this.elemCurrent.animate(cssFin,500);
        $('.sidenav').removeClass('active');
        $("#rub"+num).addClass("active");
//        this.elem.parent().find("#ColRight").find("ul li").removeClass("active");
        //this.elem.parent().find("#ColRight").find("ul li:eq("+(num-1)+")").addClass("active");
        this.nbCurrent=num;
       // alert(this.nbCurrent);
        this.elemCurrent=this.elem.find("#prmdf"+num);
    },

    next: function(){
        num=this.nbCurrent+1;
        if(num>this.nbSlide){
            num=1;
        }
        this.gotoSlide(num);
    },

    Prev: function(){
        num=this.nbCurrent-1;
        if(num<1){
            num=this.nbSlide;
        }
        this.gotoSlide(num);
    }


}
if($('.demandType').parent().find('input[type=radio]:checked').val()!=2){
$('.demandType').parent().parent().next("div").hide();
}
$('.demandType').live('change',function(){
    //alert($(this).val());
    if($(this).val()!=2){
        $(this).parent().parent().next("div").slideUp();
         $(this).parent().parent().next("div").find('input[type=radio]').removeAttr("checked");
    }else{
        $(this).parent().parent().next("div").slideDown();
        $(this).parent().parent().next("div").find('input[type=radio]').removeAttr("checked");
    }
});

$(".test").live('change',function(){
   id=$(this).val();
   $.post("/alwprmdform/users/userinfo/"+id,function(data){
      $('.UserInformation').empty().append(data);
      $('.UserInformation').show();
   });
});
$(".hasNmBtn").live('click',function(){
   if($(this).next('div').is(':hidden')){
       //alert("1");
        $("#newmanagerHasnewmanager").val(1);
    }else{
        //alert("2");
        $("#newmanagerHasnewmanager").val(0);
    }
});
